package com.gh.blog.controller;

import com.gh.blog.dto.StudentDetailDTO;
import com.gh.blog.dto.StudentInfoDTO;
import com.gh.blog.entity.Student;
import com.gh.blog.service.StuService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Author Fawn
 * @Date 2020/8/11 22:51
 * @Version 1.0
 **/
@RestController
public class StuController {

    @Autowired
    private StuService stuService;

    @RequestMapping("findAll")
    public List<Student> findAll(@Valid @RequestBody Integer a){
        return stuService.findAll();
    }

    @RequestMapping("findByPage")
    public PageInfo<Student> findByPage(@RequestParam("current") Integer current,
                                        @RequestParam("size") Integer size){
        return stuService.findByPage(current, size);
    }

    @GetMapping("detail")
    public StudentDetailDTO studentDetail(String no) {
        StudentDetailDTO studentDetail = stuService.findDetail(no);

        return studentDetail;
    }

    @GetMapping("info")
    public StudentInfoDTO findStuInfo(String no) {
        StudentInfoDTO StudentInfoDTO = stuService.findStuInfo(no);

        return StudentInfoDTO;
    }
}
